home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11602 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.1 KB  |  36 lines

  1. Path: doors.informatik.uni-siegen.de!plrunu
  2. From: plrunu@informatik.uni-siegen.de (Runu Knips)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: ?Callbacks / Pointer to member functions?
  5. Date: 15 Mar 1996 12:49:38 GMT
  6. Organization: University of Siegen
  7. Sender: plrunu@doors.informatik.uni-siegen.de (Runu Knips)
  8. Distribution: world
  9. Message-ID: <4ibp12$br5@si-nic.hrz.uni-siegen.de>
  10. References: <4i9b3s$7tt@serveru1.naic.wpafb.af.mil>
  11. NNTP-Posting-Host: doors.informatik.uni-siegen.de
  12. Keywords: Callbacks Pointers Member Functions
  13.  
  14.  
  15. Motif is C. C doesn't know about classes. If you want
  16. to declare a member function with may be called by
  17. C functions, you have to declare it the following
  18. way:
  19.  
  20. class X {
  21.     ....
  22.     static void Func (void);
  23.     ....
  24. };
  25.  
  26. The 'static' says 'this function doesn't have a 
  27. this pointer'. It is a member function which doesn't
  28. know by which class instance it is owned.
  29.  
  30. Therefore, if this object should be reusable, you
  31. should store in each Motif-Button (or Window or
  32. else) the this-pointer to the corresponding C++-
  33. Object, so you may get it out of the parameters
  34. (I hope the callback function will get the
  35. button as parameter!) of the callback function.
  36.